<?php
if (!defined('WEB_ROOT')) {
	exit;
}
if (isset($_GET['mannc']) && $_GET['mannc'] !='') {
	$mannc = $_GET['mannc'];
	$queryString = "&mannc=$mannc";
} else {
	$mannc = '';
	$queryString = '';
}
	
// for paging
// how many rows to show per page
$rowsPerPage = 5;

$sql = "SELECT matg, hotentg, ngaysinh, madv,tgn.nhomnc_id
        FROM tacgia tg left join tacgia_nhomnc tgn ON tg.id = tgn.tg_id
		ORDER BY matg";
//echo $sql;
$result     = dbQuery(getPagingQuery($sql, $rowsPerPage));
$pagingLink = getPagingLink($sql, $rowsPerPage);
		
//$groupList = buildGroupOptions($mannc);

?> 
<p>&nbsp;</p>
<form action="processAuthor.php?action=addAuthor" method="post"  name="frmListAuthor" id="frmListAuthor">
 <!--<table width="100%" border="0" cellspacing="0" cellpadding="2" class="text">
  <tr>
   <td align="right">View authors in : 
    <select name="cboGroup" class="box" id="cboGroup" onChange="viewAuthor();">
     <option selected>All Group</option>
	//<?php echo $groupList; ?>
   </select>
 </td>
 </tr>
</table>-->
<br>
 <table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="text">
	  <tr align="center" id="listTableHeader"> 
		   <td width="90">Mã tác giả</td>
		   <td>Họ tên tác giả</td>
			<!--   <td width="75">Hình ảnh</td>-->
		   <td width="60">Ngày sinh</td>
		   <td width="70">Đơn vị</td>
		   <td width="40">Sửa</td>
		   <td width="40">Xóa</td>
	  </tr>
  <?php
$parentId = 0;
if (dbNumRows($result) > 0) {
	$i = 0;
	
	while($row = dbFetchAssoc($result)) {
		extract($row);
		
		if ($pd_thumbnail) {
			$pd_thumbnail = WEB_ROOT . 'images/product/' . $pd_thumbnail;
		} else {
			$pd_thumbnail = WEB_ROOT . 'images/no-image-small.png';
		}		
		if ($i%2) {
			$class = 'row1';
		} else {
			$class = 'row2';
		}
		
		$i += 1;
?>
  <tr class="<?php echo $class; ?>"> 
	   <td width="90" align="center"><a href="index.php?view=detail&matg=<?php echo $matg; ?>"><?php echo $matg; ?></a></td>
			<!--   <td width="75" align="center"><img src="<?php echo $pd_thumbnail; ?>"></td>-->
	   <td><?php echo $hotentg; ?></td>
 	   <td width="60" align="center"><?php echo $ngaysinh; ?></td>
	   <td width="70" align="center"><?php echo $madv; ?></td>

	   <td width="40" align="center"><a href="javascript:modifyAuthor('<?php echo $matg; ?>', <?php echo $nhomnc_id; ?>);">Sửa</a></td>
	   <td width="40" align="center"><a href="javascript:deleteAuthor('<?php echo $matg; ?>', <?php echo $nhomnc_id; ?>);">Xóa</a></td>
  </tr>
  <?php
	} // end while
?>
  <tr> 
   <td colspan="5" align="center">
   <?php 
echo $pagingLink;
   ?></td>
  </tr>
<?php	
} else {
?>
  <tr> 
   <td colspan="5" align="center">No Authors Yet</td>
  </tr>
  <?php
}
?>
  <tr> 
   <td colspan="5">&nbsp;</td>
  </tr>
  <tr> 
   <td colspan="5" align="right"><input name="btnAddAuthor" type="button" id="btnAddAuthor" value="Thêm tác giả" class="box" onClick="addAuthor()"></td>
  </tr>
 </table>
 <p>&nbsp;</p>
</form>